<?php
class tbl_gem_log extends AppModel
{
    public $useTable = 'tbl_gem_log';
    public $useDbConfig = 'log_db';

    public function get_gem_use_total()
    {
        $params = array(
            'conditions' => array(
                'gem_amount >' => 0
            ),
            'fields' => array(
                'sum(gem_amount) as sum',
            )
        );
        $data = $this->find('first', $params);
        return $data;
    }

    public function get_gem_use()
    {
        $params = array(
            'conditions' => array(
                'gem_amount >' => 0
            ),
            'fields' => array(
                'count(gem_use_type) as count',
                'sum(gem_amount) as sum',
                'gem_use_type'
            ),
            'group' => 'gem_use_type'
        );
        $data = $this->find('all', $params);
        return $data;
    }
}